<template>
    <div class="quarterly_report">
        <!-- 0 暂存  1 提交 2 同步 3 审核通过 4 审核驳回 -->
        <div v-if="xianshi == '0' || xianshi == '4'"> 
            <xlUntil text="在研／在孵项目情况" :queryParam="queryParam" :untilVisible="true" :importBtn="false"  :filtersVislble="true" :exportXlsData="exportXlsData" v-show="test"  :addBtn="status != 1"  v-bind="$attrs" @delBatch="delBatch" @addForm="addForm" @searchKeyWord="searchKeyWord"  :export-xls-url="url.exportXlsUrl"></xlUntil>
        </div>
        <div class="xl-table-content">
            <xlTable
                    :columns="columns"
                    :dataSource="data"
                    rowKey="id"
                    :pagination="pagination"
                    :loading="loading"
                    @change="handleTableChange"
                    bordered
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
                >
                <template v-slot:action="scope">
                   <div v-if="status == 1 || status == 3">
                       <a @click="seeForm(scope.record)">查看</a>
                   </div>
                   <div v-else>
                        <a @click="editForm(scope.record)" v-if="test">编辑</a>
                        <a @click="seeForm(scope.record)" v-else>查看</a>
                        <a-divider type="vertical"/>
                        <a-dropdown v-if="test">
                            <a class="ant-dropdown-link" >更多 <a-icon type="down"/></a>
                            <a-menu slot="overlay" >
                                <a-menu-item @click="quarterForm(scope.record)">
                                    <a>季度填报</a>
                                </a-menu-item>
                                <a-menu-item @click="seeForm(scope.record)">
                                    <a>查看</a>
                                </a-menu-item>
                                <a-menu-item>
                                    <a-popconfirm title="确定删除吗?" @confirm="() => delForm(scope.record.id)">
                                        <a>删除</a>
                                    </a-popconfirm>
                                </a-menu-item>
                            </a-menu>
                        </a-dropdown>
                   </div>
                </template>
            </xlTable>
        </div>
        <xlForm ref="xlForm" @handleOk="handleOk"></xlForm>
        <monForm :column="2" ref="monForm" @handleOk="handleOk"></monForm>
        <seeForm ref="seeForm"></seeForm>
    </div>
</template>

<script>

    import xlMixin from '../../mixin/index'
    import xlUntil from '../../../components/xlUntil/index'
    import seeForm from '../../../views/new/hatch_project/model/see'
    import monForm from '../../../views/new/hatch_project/model/form'
    export default {
        name: "index",
        components:{
            xlUntil,
            seeForm,
            // xlForm
        },
        mixins:[xlMixin],
        data(){
            return{
                form:{},
                columns:[
                    {
                        title: '编号',
                        key: 'rowIndex',
                        align: "center",
                        fixed: 'left',
                        width:'80px',
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1;
                        }
                    },
                    {
                        title: '项目名称',
                        dataIndex: 'projectName',
                        fixed: 'left',
                        required: true,
                        type:'assignSelect',
                        typeData:{
                            url:'/ndo/api/ndo/hatch/project/page/_list',
                            selectValue:'id',
                            selectName:'projectName',
                            addBtn:true,
                            editType:1
                        }
                    },
                    {
                        title: '处于阶段',
                        dataIndex: 'stage',
                        type:'select',
                        typeData:'NDO_PROJECT_STAGE',
                    },
                    {
                        // XY401 在研  XY402  在孵
                        title: '项目状态',
                        dataIndex: 'projectStatus',
                        type:'radio',
                        typeData:'NDO_PROJECT_STATUS',
                        conditionF:{
                            clearKey:'companyName',
                            clearValue:'XY401'
                        }
                        
                    },
                    
                    {
                        title: '孵化企业',
                        dataIndex: 'companyName',
                        required:false,
                        type:'input',
                        condition:{
                            conditionKey:'projectStatus',
                            conditionValue:'XY402'
                        }
                    },
                    {
                        title: '新研名称',
                        dataIndex: 'newDevOrgName',
                        // tableVisible:true, 列表不展示
                        formVisible: true,
                        type:'input'
                    },
                    {
                        title: '项目来源',
                        dataIndex: 'projectSource',
                        type:'select',
                        typeData:'NDO_PROJECT_SOURCE'
                    },
                    {
                        title: '产业领域',
                        dataIndex: 'industryDomain',
                        type:'select',
                        typeData:'NDO_FIELD'
                    },
                    {
                        title: '项目时间',//开始结束时间
                        dataIndex: 'beginDate',
                        type:'dateRange',
                        typeData:{
                            type:'date',
                            startDate:'beginDate',
                            endDate:'endDate'
                        },span:2
                    },
                    
                    {
                        title: '项目描述',
                        dataIndex: 'projectDesc',
                        type:'textarea'
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        fixed: 'right',
                        width:'150px',
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                exportXlsData:[
                    {
                        title:'项目编码',
                        dataIndex:'TNHP.HATCH_PROJECT_CODE'
                    },
                    {
                        title:'项目名称',
                        dataIndex:'TNHP.PROJECT_NAME'
                    },
                    {
                        title:'项目来源',
                        dataIndex:'TNHP.PROJECT_SOURCE'
                    },
                    {
                        title:'产业领域',
                        dataIndex:'TNHP.INDUSTRY_DOMAIN'
                    },
                    {
                        title:'项目开始时间',
                        dataIndex:'TNHP.BEGIN_DATE'
                    },
                    {
                        title:'项目结束时间',
                        dataIndex:'TNHP.END_DATE'
                    },
                    {
                        title:'项目状态',
                        dataIndex:'TNHP.PROJECT_STATUS'
                    },
                    {
                        title:'项目描述',
                        dataIndex: 'TNHP.PROJECT_DESC'
                    },
                    {
                        title:'项目阶段',
                        dataIndex: 'TNHP.STAGE'
                    },
                    {
                        title:'企业名称',
                        dataIndex:'TNHP.COMPANY_NAME'
                    },
                    {
                        title:'新型研发机构名称',
                        dataIndex:'TNBI.NEW_DEV_ORG_NAME'
                    }
                ],
                paramMore:{
                    "newDevOrgId": '',
                },
                url: {
                    list: "/ndo/api/ndo/hatch/project/page/list",
                    add: '/ndo/api/ndo/hatch/project/save',
                    edit: '/ndo/api/ndo/hatch/project/save',
                    delete: "/ndo/api/ndo/hatch/project/remove",
                    deleteBatch: "/api/ndo/hatch/project/remove",
                    exportXlsUrl: "/ndo/api/new/dev/org/export/project",
                    importExcelUrl: "ndo/api/ndo/hatch/project/importExcel",
                    importExcelDemoUrl:'/ndo/api/ndo/hatch/project/importTemplate'
                }
            }
        },
        props:{
            newDevOrgId:Number,
            test:Boolean,
            status,
            xianshi:String, 
            code:String,   // 填报code
            reportId:Number, //填报id
        },
        created(){
            this.paramMore.newDevOrgId = this.newDevOrgId
            console.log(this.newDevOrgId,this.code,1111)
            this.formatMerge()
            this.pageOnload()
        },
        watch:{
            newDevOrgId(){
                this.paramMore.newDevOrgId = this.newDevOrgId
                console.log(this.newDevOrgId,this.code,1111)
                this.pageOnload()
            }
        },
        methods:{
             addForm() {
                this.$refs.xlForm.tableTitle = '新增'
                this.$refs.xlForm.formatData(this.columns)
                this.$refs.xlForm.visible = true
                this.$refs.xlForm.confirmLoading = false
                this.$refs.xlForm.formatForm({
                    companyName:''
                })
                this.$refs.xlForm.type = 1
            },
            monForm(data){
                this.$refs.monForm.tableTitle = '月度经营数据'
                this.$refs.monForm.formatData(data,1)
                this.$refs.monForm.visible = true
                this.$refs.monForm.confirmLoading = false
                this.$refs.monForm.formatForm({})
                // this.$refs.monForm.type = true
            },
            quarterForm(data){
                this.$refs.monForm.tableTitle = '季度经营数据'
                this.$refs.monForm.formatData(data,2,this.code,this.reportId)
                this.$refs.monForm.visible = true
                this.$refs.monForm.confirmLoading = false
                this.$refs.monForm.formatForm({})
                // this.$refs.monForm.type = false
            },
            seeForm(data){
                this.$refs.seeForm.formatForm(data)
                this.$refs.seeForm.visible = true
            }
        },
        components:{
            seeForm,
            monForm
        }
    }
</script>
<style scoped>

</style>
